#include "cute.h"
#include "ide_listener.h"
#include "xml_listener.h"
#include "cute_runner.h"

extern "C" {
#include "lexer.h"
#include "LexVal.h"
#include "lex-tools.h"
#include "parser.h"
#include "Label.h"
#include "LabelList.h"
#include "Hash-tools.h"
}

#include <stdlib.h>
#include <iostream>

using namespace std;

void testLabelList(){
	PlabelList list=initLabelList();

	Plabel id1=initLabel("Foo",LABEL_PUBLIC);
	Plabel id2=initLabel("bar",LABEL_PACKAGE);
	Plabel id3=initLabel("ex",LABEL_PUBLIC);

	ASSERT_EQUALM("size of list not 0!",0,getLabelListSize(list));
	cout << "starting list: ";
	printLabelList(stdout,list);

	addLabelToLabelList(id1,list);
	ASSERT_EQUALM("size of list not 1!",1,getLabelListSize(list));

	addLabelToLabelList(id2,list);
	addLabelToLabelList(id3,list);

	ASSERT_EQUALM("size of list not 3!",3,getLabelListSize(list));
	printLabelList(stdout,list);

	ASSERT_EQUALM("can't find the label id2!",id2,findLabelInLabelList(id2,list));

	removeLabelFromLabelList(id2,list);

	ASSERT_EQUALM("We can find the just-removed label id2!",NULL,findLabelInLabelList(id2,list));
}

void testDirectHash(){
	//TODO I should setup a test for it
	//SV should collide with Pt
	//g5 should collide with as
	/*DirectHash hash1=hashString("SV");
	DirectHash hash2=hashString("Pt");
	ASSERT_EQUALM("SV and Pt hashes are not conflicting!",hash1,hash2);
	DirectHash hash3=hashString("g5");
	DirectHash hash4=hashString("as");
	ASSERT_EQUALM("g5 and as hashes are not conflicting!",hash3,hash4);*/
}

void runAllTests(int argc, char const *argv[]){
	cute::suite s;
	s.push_back(CUTE(testDirectHash));
	//TODO add your test here
	cute::xml_file_opener xmlfile(argc,argv);
	cute::xml_listener<cute::ide_listener<> >  lis(xmlfile.out);
	cute::makeRunner(lis,argc,argv)(s, "AllTests");
}

int main(int argc, char const *argv[]){
    runAllTests(argc,argv);
    return 0;
}



